package cpgears.movie.widget {
	import asunit.framework.TestCase;
	import cpgears.BaseImplMock;
	import cpgears.movie.container.ContainerType;
	import cpgears.movie.IMovie;
	import cpgears.movie.MovieMock;
	import cpgears.properties.WidgetPropertiesBase;
	
	/**
	 * ...
	 * @author Whyves
	 */
	public class WidgetInfoTest extends TestCase{
		
		private var mWidgetProperties:WidgetPropertiesBase = null;
		
		public function WidgetInfoTest(testMethod:String = null) {
			super(testMethod);
		}
		
		override protected function setUp():void {
			mWidgetProperties = new WidgetPropertiesBase(prototype)
		}

		//---------------------------------------------------------------------
		//  Widget Container
		//---------------------------------------------------------------------
		public function testWidgetContainer():void {
			triggerEnterRuntime(assertWidgetContainer);
		}
		
		private function assertWidgetContainer(functionCalled:String, properties:Object, movie:IMovie):void {
			assertSame(ContainerType.SLIDE, movie.widget.containerType);
		}
		
		//---------------------------------------------------------------------
		//  Widget Visibility
		//---------------------------------------------------------------------
		public function testWidgetVisibility():void {
			triggerEnterRuntime(assertWidgetVisibility);
		}
		
		private function assertWidgetVisibility(functionCalled:String, properties:Object, movie:IMovie):void {
			assertTrue("Widget should have been visible",movie.widget.isWidgetVisible());
			assertTrue("Widget should have been enabled", movie.widget.isWidgetEnabled());
		}
		
		//---------------------------------------------------------------------
		//
		//  Helper functions
		//
		//---------------------------------------------------------------------
		
		private function triggerEnterRuntime(callback:Function):void {
			var handler:Function = addAsync(callback, 500);
			var widget:BaseImplMock = new BaseImplMock(handler);
			widget.cpSetValue("movieHandle",  new MovieMock(mWidgetProperties));
		}
	}
}